package com.qzimp.fujiancuo.utils;

import cn.hutool.crypto.SecureUtil;

import java.security.SecureRandom;

public class StringUtil {
    //生成六位随机字符串
    public static String generateSixCharString(int size) {
        // 定义可能的字符
        String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        // 创建SecureRandom实例
        SecureRandom random = new SecureRandom();
        StringBuilder sb = new StringBuilder(size);
        // 循环6次，每次随机选择一个字符
        for (int i = 0; i < size; i++) {
            int index = random.nextInt(characters.length());
            sb.append(characters.charAt(index));
        }
        return sb.toString();
    }

    public  static String MD5(String str){
       return SecureUtil.md5(str);
    }

}
